/********************************************************************
	filename: 	Trilinear.h
	created:	2010/04/22
	author:		Xiuwei Chen

	purpose:	Definition of trilinear coordinate

	All rights Reserved
*********************************************************************/

#pragma once

#include "Const.h"
#include "Vector2D.h"
#include "Triangle2D.h"

class Trilinear
{
public:
	/// <Summary>
	/// Zero of Trilinear
	/// </Summary>
	const static Trilinear Zero;

	/// <Summary>
	/// proportion of the trilinear coordinate
	/// </Summary>
	double u0, u1, u2;

	/// <Summary>
	/// default constructor
	/// </Summary>
	Trilinear();

	/// <Summary>
	/// copy constructor
	/// </Summary>
	Trilinear(const Trilinear& t);

	/// <Summary>
	/// constructor
	/// </Summary>
	Trilinear(double _u0, double _u1, double _u2);

	/// <Summary>
	/// constructor
	/// </Summary>
	Trilinear(const Point2D &p, const Triangle2D &_triangle);

	/// <Summary>
	/// set value
	/// </Summary>
	void SetValue(double _u0, double _u1, double _u2);

	/// <Summary>
	/// set value
	/// </Summary>
	void SetValue(const Point2D &p, const Triangle2D &triangle);

	/// <Summary>
	/// overload operation: assignment
	/// </Summary>
	Trilinear & operator = (const Trilinear &t);

	/// <Summary>
	/// overload operation: "=="
	/// </Summary>
	bool operator == (const Trilinear &t);

	/// <Summary>
	/// overload operation: "!="
	/// </Summary>
	bool operator != (const Trilinear &t);

	/// <Summary>
	/// Normalize
	/// </Summary>
	void Normalize();

	/// <Summary>
	/// sum of u0, u1, u2
	/// </Summary>
	double Sum();

};
